<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 给函数的参数设置默认值 => 如果不传参就使用默认值

    // ES5
    // function add(a, b) {
    //     a = a === undefined ? 0 : a;
    //     b = b === undefined ? 0 : b;

    //     console.log(a, b);
    //     return a + b;
    // }

    // ES6  函数参数设置默认值
    function add(a = 0, b = 0) {
        console.log(a, b);
        return a + b;
    }

    // console.log(add(1, 2));
    console.log(add());








</script>

</html>